#!/usr/bin/env perl
use strict;
use warnings;
use POSIX;
use yaptest;
use File::Basename;

my $script_name = basename($0);
my $usage = "Usage: $script_name
Runs metasploit-exploit-suggest.pl over all nbe's by nessus.
This has to be run after nessus!

NB: 	You must have metasploit_path set in your config file, 
	and metasploit-exploit-suggest.pl must be in your path.

";

die $usage if shift;
my $commit = 1;
my $y = yaptest->new();
my $msf_dir = $y->get_config('metasploit_3_dir');

if (defined($msf_dir)) {
        $msf_dir .= '/' unless substr($msf_dir, -1, 1); # add trailing slash
} else {
        print "ERROR: metasploit_3_dir config option not set.  Use yaptest-config.pl\n";
        print "         to set 'metasploit_3_dir' to the location of Metasploit v3\n";
        exit 1;
}
print "\n";

system("metasploit-exploit-suggest.pl -m $msf_dir *.nbe | tee metasploit-exploit-suggest.out");